package com.wg.mycat.separation.repository;

import com.wg.mycat.separation.domain.MycatInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

@Transactional
public interface MycatInfoRepository extends JpaRepository<MycatInfo, String>, JpaSpecificationExecutor<MycatInfo> {

    @Modifying
    @Query(value = "insert into mycat_info values (?1,?2,?3,?4)",nativeQuery = true)
    int insertMycatInfo(@Param("id") String id, @Param("name") String name, @Param("age") int age, @Param("position") String position);

    @Modifying
    @Query(value = "update mycat_info mi set mi.name = ?2 where mi.id = ?1 ",nativeQuery = true)
    int updateMycatInfo(String id, String name);

}
